package org.ichow.scenegame.controller
{
	import flash.display.Sprite;
	import org.ichow.scenegame.core.MovieManager;
	import org.ichow.scenegame.core.NotiFactory;
	import org.ichow.scenegame.core.ToolsBar;
	import org.ichow.scenegame.core.ToolTip;
	import org.ichow.scenegame.events.SceneEvent;
	import org.ichow.scenegame.model.AssetsProxy;
	import org.ichow.scenegame.model.MusicProxy;
	import org.ichow.scenegame.notis.HelpNoti;
	import org.ichow.scenegame.SceneGameFacade;
	import org.ichow.scenegame.view.*;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;

	/**
	 * ...
	 * 初始化视图命令
	 * 视图绑定到代理中
	 * @author M.ichow
	 */
	public class ViewPrepCommand extends SimpleCommand
	{

		override public function execute( notification : INotification ) : void
		{
			super.execute( notification );
			//移除加载完成通知
			if ( facade.hasCommand( AssetsProxy.ASSETS_COMPLETE ) )
				facade.removeCommand( AssetsProxy.ASSETS_COMPLETE );
			// 素材代理
			var _proxy : AssetsProxy = facade.retrieveProxy( AssetsProxy.NAME ) as AssetsProxy;
			var _scene : SceneMediator = facade.retrieveMediator( SceneMediator.NAME ) as SceneMediator;
			//背景音乐
			facade.registerProxy(new MusicProxy( _scene.getValueForKey("flashPath") as String , _proxy.getConfig("backGroundMusic") ));
			//动画
			facade.registerMediator( new MovieMediator( new MovieManager() ) );
			//通知
			facade.registerMediator( new NotiMediator( new NotiFactory() ) );
			//工具条
			facade.registerMediator( new ToolsBarMediator( new ToolsBar( _proxy.getSkin( "ToolsBar_mc" ) ) ) );
			//提示
			facade.registerMediator( new ToolTipMediator( ToolTip.getInstance() ) );
			//游戏帮助
			facade.registerMediator( new HelpMediator( new HelpNoti() ) );
			//创建视图完成 发出初始化通知
			sendNotification( SceneEvent.INIT_GAME );
		}

	}

}